﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DomainDriver.CommonUtilities.Enums;
using DomainDriver.DomainModeling.DataProviders;
using DomainDriver.DomainModeling.GenericUnitTesting.Repositories;
using AutomotivePricingModel.BodyStyles;

namespace AutomotivePricingModel.UnitTests.Repositories
{
    [TestFixture(new object[] { DataSourcePersistenceType.None })]
    [TestFixture(new object[] { DataSourcePersistenceType.File })]
    [TestFixture(new object[] { DataSourcePersistenceType.Database })]
    public class BodyStyleRepositoryTests : RepositoryTestFixture<AutomotivePricingDomainModel, BodyStyleEnum, BodyStyle>
    {
        protected int m_CurrentKeyValue = int.MinValue;

        public BodyStyleRepositoryTests(DataSourcePersistenceType persistenceType)
            : base(persistenceType)
        { }

        protected override AutomotivePricingDomainModel CreateDomainModel(DataSourcePersistenceType persistenceType, bool buildModelWithConstraints)
        {
            AutomotivePricingDomainModel model = new AutomotivePricingDomainModel(persistenceType, buildModelWithConstraints);
            return model;
        }

        protected override BodyStyle CreateDomainObject()
        {
            BodyStyleEnum keyValue = (BodyStyleEnum)m_CurrentKeyValue++;
            BodyStyle domainObject = new BodyStyle(keyValue);
            domainObject.DisplayName = domainObject.Key.ToString();
            return domainObject;
        }

        protected override void UpdateDomainObject(BodyStyle domainObject, ref bool objectCanBeUpdated)
        {
            objectCanBeUpdated = true;
            domainObject.DisplayName += " UPDATED";
        }

        [SetUp]
        public override void SetUp()
        {
            base.SetUp();

            Array enumValues = Enum.GetValues(typeof(BodyStyleEnum));
            NumberOfTestInstances = enumValues.Length;
            m_CurrentKeyValue = EnumUtilities.GetMinEnumValue<BodyStyleEnum>();
        }
    }
}